package cn.ecnu.mapper;

import cn.ecnu.pojo.ConsultantSupervisorConnector;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ConsultantSupervisorConnectorMapper {

    /**
     * 根据咨询师ID删除所有和它绑定的关系
     * @param consultantId 咨询师ID
     * @return 是否删除成功
     */
    @Delete("DELETE FROM psychology.consultant_supervisor_connector WHERE consultant_id = #{id}")
    int deleteAllBindingByConsultantId(@Param("id") Integer consultantId);

    /**
     * 根据督导ID删除所有和它绑定的关系
     * @param supervisorId 督导ID
     * @return 是否删除成功
     */
    @Delete("DELETE FROM psychology.consultant_supervisor_connector WHERE supervisor_id = #{id}")
    int deleteAllBindingBySupervisorId(@Param("id") Integer supervisorId);

    /**
     * 新增绑定关系
     * @param connector 绑定对象
     * @return 是否绑定成功
     */
    int insertConnector(ConsultantSupervisorConnector connector);

    /**
     * 获取督导绑定的所有咨询师ID
     * @param supervisorId 督导ID
     * @return 绑定的咨询师的ID列表
     */
    @Select("SELECT psychology.consultant_supervisor_connector.consultant_id FROM psychology.consultant_supervisor_connector WHERE supervisor_id = #{id}")
    List<Integer> getConsultantIdsBySupervisorId(@Param("id") Integer supervisorId);
}
